<template>
  <div>
    <el-form  label-width="80px" style="text-align: left;">
      <el-form-item label="病人姓名">
        <el-input v-model="param.caseName" :readonly="true"></el-input>
      </el-form-item>
      <el-form-item label="手术名称" >
        <el-select placeholder="请选择" v-model="param.sdSiid">
          <el-option :label="surgeryItem.siName" :key="surgeryItem.id" :value="surgeryItem.id" v-for="surgeryItem in AllSurgeryItem"></el-option>
        </el-select>
        选择日期：
        <el-date-picker
          type="date"
          placeholder="选择日期"
          value-format="yyyy-MM-dd"
          v-model="param.sdDate"
          >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="开单医生">
        <el-select placeholder="请选择" v-model="param.sdWorkerid">
        <el-option :label="doctor.wkName" :key="doctor.id" :value="doctor.id" v-for="doctor in allDoctor"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="addSurgeryRequest">确定</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props:{
        message: {
          type: Object,
          required: true
        }
      },

  data() {
    return {
      param:{},
      allDoctor:[],
      AllSurgeryItem:[]
    }
  },

  methods: {
    queryAllDoctor(){
      this.$axios.get('api/doctor/queryAllDoctor').then(resp=>{
        if(resp.data.code==200){
          this.allDoctor=resp.data.data
          // console.log(resp.data)
        }
      })
    },

    queryAllSurgeryItem(){
      this.$axios.get('api/doctor/queryAllSurgeryItem').then(resp=>{
        if(resp.data.code==200){
          this.AllSurgeryItem=resp.data.data
        }
      })
    },

    addSurgeryRequest(){
      this.$axios.post('api/doctor/addSurgeryRequest',this.param).then(resp=>{
        if(resp.data.code==200){
          this.$message({
                showClose: true,
                message: '添加申请成功',
                type: 'success'
         });
         this.param.sdSiid=''
         this.param.sdDate=''
         this.param.sdWorkerid=''
        }
      })
    },



    text(){
      this.param.sdCaseid=this.message.caseId
      this.param.caseName=this.message.caseName
     }
  },

  created(){
    this.text()
    this.queryAllDoctor()
    this.queryAllSurgeryItem()
  }
}
</script>

<style scoped>
</style>